<template>
	<view>
		<view @tap.stop="goDetail(index,'detail')" class="flex-y-center mt-sm ml-md mr-md pd-sm fill-base radius-16"
			v-for="(item,index) in list" :key="index">
				<image mode="aspectFill" class="cover radius" style="width: 100rpx; height: 100rpx;" :src='userinfo.avatar_thumb'></image>
				<view class="flex-1 mt-lg ml-md">
					<view class="flex-y-baseline mb-md">
						<view class="f-title c-title text-bold max-400 ellipsis">
							{{item.status_name}}
						</view>
					</view>
					<view class="flex-y-baseline mb-md">
						<view class="flex-y-center f-caption c-caption">订单号：{{item.orderno}}</view>
						
					</view>	
					<view class="flex-y-baseline mb-md">
						<view class="flex-y-center f-caption c-caption">日期：{{item.addtime}}</view>
						<view class="flex-y-center f-caption c-caption ml-md">金额：{{item.money}}</view>
						<view class="flex-y-center f-caption c-caption" style="margin-left: 30rpx;">{{item.name}}</view>
					</view>
					
				</view>
		</view>
		
		<load-more :noMore="list.current_page>=list.last_page&&list.data.length>0" :loading="loading" v-if="loading">
		</load-more>
		<abnor v-if="!loading&&list.length<=0&&list.current_page==1"></abnor>

		<view class="space-footer"></view>
	</view>
</template>

<script>
	import {
		mapState,
		mapActions,
		mapMutations
	} from "vuex"
	import tabbar from "@/components/tabbar.vue"
	export default {
		components: {
			tabbar
		},
		data() {
			return {
				options: {},
				loading: true,
				list: [],
				param: {},
				userinfo:{}
			}
		},
		computed: mapState({
			primaryColor: state => state.config.configInfo.primaryColor,
			subColor: state => state.config.configInfo.subColor,
			configInfo: state => state.config.configInfo,
			userInfo: state => state.user.userInfo,
		}),
		async onLoad(options) {
			await this.initIndex()
			this.userinfo = uni.getStorageSync('userInfo')
		},
		onPullDownRefresh() {
			this.initRefresh();
			uni.stopPullDownRefresh()
		},
		onReachBottom() {
			if (this.list.current_page >= this.list.last_page || this.loading) return;
			this.loading = true;
			this.getList(this.param.page + 1);
		},
		methods: {
			...mapActions(['getConfigInfo']),
			async initIndex(refresh = false) {
				await this.getList(1)
				this.$util.setNavigationBarColor({
					bg: this.primaryColor
				})
			},
			initRefresh() {
				this.initIndex(true)
			},
			async getList(page = 0) {
				let newList = await this.$api.user.cashList(this.param);
				this.list = newList

				this.loading = false
				this.$util.hideAll()
			},
			// 订单详情/申请退款/去评价
			goDetail(index, page) {
				let {
					id
				} = this.list.data[index]
				let url = `/user/pages/order/${page}?id=${id}`
				this.$util.goUrl({
					url
				})
			}
		}
	}
</script>


<style lang="scss">
	.list-item2 {
		float: left;
		box-sizing: border-box;
		width: 45%;
		height: 400rpx;
		padding: 10px 6px;
		
		background-position: center;
		background-size:cover;
		background-repeat: no-repeat;
		
		.member-tag {
			width: 168rpx;
			height: 46rpx;
			background: #0e0f0f;
		
			.iconfont {
				font-size: 28rpx;
			}
		}
		
		.cover {
			width: 180rpx;
			height: 180rpx;
		}
		
		.text {
			width: 75rpx;
			height: 75rpx;
		}
	
		.text-delete {
			font-size: 20rpx;
			color: #B9B9B9;
		}
	
		.item-btn {
			width: 130rpx;
			height: 52rpx;
			border-radius: 8rpx;
		}
	}
</style>
